@medusajs/medusa
Version:
Building blocks for digital commerce
59 lines • 1.93 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.DELETE = exports.POST = void 0;
const core_flows_1 = require("@medusajs/core-flows");
const utils_1 = require("@medusajs/framework/utils");
const POST = async (req, res) => {
const { id, action_id } = req.params;
const remoteQuery = req.scope.resolve(utils_1.ContainerRegistrationKeys.REMOTE_QUERY);
const { result } = await (0, core_flows_1.updateExchangeAddItemWorkflow)(req.scope).run({
input: {
data: { ...req.validatedBody },
exchange_id: id,
action_id,
},
});
const queryObject = (0, utils_1.remoteQueryObjectFromString)({
entryPoint: "order_exchange",
variables: {
id,
filters: {
...req.filterableFields,
},
},
fields: req.queryConfig.fields,
});
const [orderExchange] = await remoteQuery(queryObject);
res.json({
order_preview: result,
exchange: orderExchange,
});
};
exports.POST = POST;
const DELETE = async (req, res) => {
const remoteQuery = req.scope.resolve(utils_1.ContainerRegistrationKeys.REMOTE_QUERY);
const { id, action_id } = req.params;
const { result: orderPreview } = await (0, core_flows_1.removeItemExchangeActionWorkflow)(req.scope).run({
input: {
exchange_id: id,
action_id,
},
});
const queryObject = (0, utils_1.remoteQueryObjectFromString)({
entryPoint: "order_exchange",
variables: {
id,
filters: {
...req.filterableFields,
},
},
fields: req.queryConfig.fields,
});
const [orderExchange] = await remoteQuery(queryObject);
res.json({
order_preview: orderPreview,
exchange: orderExchange,
});
};
exports.DELETE = DELETE;
//# sourceMappingURL=route.js.map
;